package com.supinfo.sun.sungamers.games;
import java.util.InputMismatchException;

import com.supinfo.sun.sungamers.enums.Level;
import com.supinfo.sun.sungamers.exceptions.InvalidUserEntryException;
import com.supinfo.sun.sungamers.exceptions.UserAttemptException;

/**
 * @author Liu, Bing(Locke)
 * @since 2011-04-05
 * @version 0.3
 */
public abstract class FinderGame {
	protected Level level;
	
	protected boolean won;
	
	protected int allowedAttempts;

	public FinderGame() {}
	
	public void initGame() {
		switch (level) {
		case EASY:
			allowedAttempts = 10;
			break;
		case MEDIUM:
			allowedAttempts = 7;
			break;
		case HARD:
			allowedAttempts = 5;
			break;
		default:
			System.out.println("failed...");
			break;
		}
	}

	public void displayFinalMessage() {
		if (won == true)
			System.out.println("Congratulations!");
	}
	
	public abstract void play();
	
	public abstract Object readUserEntry() throws InvalidUserEntryException, InputMismatchException;
	
	public Level getLevel() {
		return level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}

	public boolean isWon() {
		return won;
	}

	public void setWon(boolean won) {
		this.won = won;
	}

	public int getAllowedAttempts() {
		return allowedAttempts;
	}

	public void setAllowedAttempts(int allowedAttempts) {
		this.allowedAttempts = allowedAttempts;
	}
	
	public abstract void addUserAttempt(Object userEntry) throws UserAttemptException;
}
